package com.example.demo.controller;

import com.example.demo.impl.OrderServiceImpl;
import com.example.demo.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Order")
@CrossOrigin(origins="http://localhost:8080")
public class Ordercontroller {

    @Autowired
    OrderServiceImpl OrderService;

    @GetMapping("/getall")
    public Object findall()
    {
        return OrderService.getList();
    }
    @GetMapping("/state")
    public Object findBy_state(int state)
    {
        return OrderService.getstateList(state);
    }
    @GetMapping("/id")
    public Object findBy_id(Integer id)
    {
        if(id != null){
            return OrderService.getidList(id);
        }
        else {
            return OrderService.getList();
        }
    }
    //取消订单
    @GetMapping("/modify")
    public Boolean modify(int orderid)
    {
        return OrderService.getmodify(orderid);
    }
    //支付订单
    @GetMapping("/modify1")
    public Boolean modify_state1(int orderid)
    {
        return OrderService.getmodify1(orderid);
    }
    //确认发货
    @GetMapping("/modify3")
    public Boolean modify_state3(int orderid)
    {
        return OrderService.getmodify3(orderid);
    }
    //确认收货
    @GetMapping("/modify4")
    public Boolean modify_state4(int orderid)
    {
        return OrderService.getmodify4(orderid);
    }
    //申请退单
    @GetMapping("/modify2")
    public Boolean modify_state2(int orderid)
    {
        return OrderService.getmodify2(orderid);
    }
    //同意退单
    @GetMapping("/modify5")
    public Boolean modify_state5(int orderid)
    {
        return OrderService.getmodify5(orderid);
    }
}
